<template>
	<view class="container-shop"
		style="">
		<scroll-view scroll-y="true" class="main">
			<!-- <view class="content"> -->
					<swiper class="swiper" circular indicator-dots autoplay :interval="5000"
						indicator-active-color="#fff" :duration="500" style="height: 480rpx;">
						<swiper-item v-for="item in imageList" :key="item.src">
							<view class="" style="height: 100%;">
								<image style="width: 100%;height: 100%" :src="item.image" mode=""></image>
							</view>
						</swiper-item>
					</swiper>
			<!-- </view> -->
			<view class="shopBox" v-if="goodsList">
				<view class="">
					<u-sticky>
						<u-tabs :list="typeList" @change="change" :activeStyle="{
							color: '#000',fontWeight: 'bold',transform: 'scale(1.05)'}" :inactiveStyle="{
								color: '#717171',
								transform: 'scale(1)'}"></u-tabs>
					</u-sticky>
				</view>
				<view class="shopList" v-if="tabIndex">
					<view class="shop-item" v-for="(item,index) in goodsList" :key="index"
						@tap="$fun.jump(`/pageC/shopDetail/shopDetail?ids=${item.id}`)">
						<view class="image">
							<image style="width: 100%;height: 100%;" :src="item.image" mode=""></image>
						</view>
						<view class="shop-title">
							<h3>{{item.name}}</h3>
							<view class="stock">
								{{$t('shop.name1')}}：{{item.stock}}
							</view>
							<view class="bottom">
								<view class="left">
									<text class="price">{{item.money}}</text>
								</view>
							</view>
						</view>
					</view>
					
				</view>
				<view class="" v-else>
					<view class="main">
						<view class="item-robot flex" v-for="(item,index) in list" :key="item.id">
							<view class="lt lt1">
								<image :src="$fun.imgUrl(item.image)" mode=""></image>
							</view>
							<view class="rt">
								<view class="title">{{item.name}}</view>
								<view class="name2">{{$t('panel.name30')}}：{{item.period}}{{$t('panel.name19')}} {{$t('panel.name28')}}：{{item.property}}</view>
								<view class="name1"></view>
								<view class="name2">{{$t('panel.name25')}}：{{$t('panel.name2')}}</view>
								<view class="flex-between">
									<text class="price">{{item.price}}</text>
									<view class="">
										<u-button type="primary" :text="$t('user.name71')" shape="circle" style="width: 160rpx;"
											color="#00A3FF" size="small" @click="handleNext(item)"></u-button>
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
				<view class="" style="margin: 50rpx; 0">
					<u-loadmore :loadmoreText="$t('equipment.name11')" dashed line />
				</view>
			</view>

		</scroll-view>
		<!-- <appUpdate v-if="appUpdateShow" :update_info="update_info" @closeModel="closeModel"></appUpdate> -->
	</view>
</template>

<script>
	import appUpdate from "@/components/yzhua006-update/app-update.vue";
	import headerTop from "@/components/dacizi-headtag/dacizi-headtag.vue"
	// import zetankSwiper from "@/component、s/zetank-swiper/components/zetank-swiper/zetank-swiper.vue"
	import {
		checkUpdate
	} from "@/components/yzhua006-update/js/app-update-check.js";
	export default {
		components: {
			headerTop,
			// zetankSwiper,
			appUpdate
		},
		data() {
			return {
				tab_title: "smartbox",
				appUpdateShow: false,
				update_info: {},
				imageList: [],
				newsList: [],
				classList: [],
				product: [],
				tabList: [],
				tabIndex: '',
				typeList: [],
				goodsList: [],
				page: 1,
				limit: 20,
				list:[]
			};
		},
		onShow() {

		},
		onLoad() {
			uni.setNavigationBarTitle({
				title:this.$t('shop.name2')
			})
			this.getBanner()
			this.getclassList()
			this.$fun.ajax.post('goods/getListType', {}).then(res => {
				this.typeList = res.data
				this.getList(this.typeList[0].id)
				this.tabIndex=this.typeList[0].id
				this.typeList.push({name:this.$t('user.name71')})
			})
		},
		// 分享好友
		onShareAppMessage() {
			return {
				title: 'smartbox',
				path: JSON.parse(uni.getStorageSync('gitH5Qrcode')),
			}
		},
		// 分享朋友圈
		onShareTimeline() {
			return {
				title: 'smartbox',
				query: JSON.parse(uni.getStorageSync('gitH5Qrcode')),
			}
		},
		onReachBottom(options) {
			if (this.page != 1) {
				this.getList()
			}
		},
		mounted() {

		},
		methods: {
			async getclassList() {
				const res = await this.$fun.ajax.post('index/category', {
					type: 'goods_icon'
				})
				this.classList = res.data
			},
			async getBanner() {
				const res = await this.$fun.ajax.post('goods/getBanner', {})
				this.imageList = res.data
			},
			async getList(id) {
				const res = await this.$fun.ajax.post('goods/getList', {
					type_id: id,
					page: this.page,
					limit: this.limit
				})
				if (res.code == 1) {
					if (res.data.length) {
						this.goodsList = [...this.goodsList, ...res.data]
						this.page++
					} else {
						this.$fun.msg(this.$t('equipment.name11'))
					}

				}

			},
			handleNext(val) {
				this.model = val
				this.money=val.price
				this.$fun.jump(
					`/pageC/robotPay/robotPay?id=${this.model.id}&url=${this.model.image}&money=${this.money}&name=${this.model.name}&type=1`
					)
			},
			async getProductList() {
				const res = await this.$fun.ajax.post('product/productList',{
						type: 1
					})
				this.list = res.data
			},
			change(e) {
				this.page = 1
				this.goodsList = []
				if(e.id){
					this.getList(e.id)
				}else{
					this.getProductList()
				}
				this.tabIndex=e.id
				console.log(e)
			},
			jump(url) {
				this.$fun.jump(url)
			}
		}
	}
</script>

<style lang="scss">
	page {
		height: 100%;
	}

	.container-shop {
		height: 100%;


		.main {
			height: 100%;
			padding-bottom: 50rpx;
		}
	}

	.content {
		.inform {
			margin: 20rpx 30rpx;

			.inform-info {
				display: flex;
				padding: 0 20rpx;
				height: 50rpx;
				border-radius: 10rpx;

				.picture {
					display: flex;
					align-items: center;
					margin-right: 30rpx;

					image {
						width: 34rpx;
						height: 34rpx;
					}
				}

				.info {
					width: 80%;
					height: 100%;

					.swiper {
						height: 500rpx;
						width: 100%;
						// height: 100%;

						.swiper-item {
							display: flex;
							align-items: center;
							width: 100%;
							height: 500rpx;

							img {
								height: 500rpx;
							}

							text {
								font-size: 24rpx;
								color: #333333;
							}
						}
					}
				}
			}
		}

		.classList {
			padding: 20rpx 0;
			margin: 30rpx 50rpx;

			.classItem {
				width: 20%;
				display: flex;
				margin-bottom: 20rpx;
				flex-direction: column;
				align-items: center;

				image {
					width: 104rpx;
					height: 104rpx;
				}

				.text {
					margin-top: 10rpx;
					color: #333333;
					font-size: 24rpx;
					font-family: Microsoft YaHei
				}
			}
		}

		.businessList {
			margin-top: 40rpx;

			.businessItem {
				margin-bottom: 20rpx;
				height: 170rpx;
				// background: #FFFFFF;
				box-shadow: 0rpx 0rpx 16rpx 0rpx rgba(0, 0, 0, 0.1);
				border-radius: 20rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;

				.l {
					margin-left: 30rpx;
					height: 100%;
					display: flex;
					align-items: center;

					image {
						width: 110rpx;
						height: 110rpx;
					}

					.text_info {
						margin-left: 30rpx;
						display: flex;
						flex-direction: column;
						justify-content: center;

						.title {
							font-size: 28rpx;
							font-family: Microsoft YaHei;
							font-weight: bold;
							color: #333333;
						}

						.text {
							margin-top: 8rpx;
							color: #333333;
							font-size: 24rpx;
						}

					}
				}

				.r {
					margin-right: 27rpx;
					width: 150rpx;
					height: 60rpx;
					// background: #FFFFFF;
					border: 2rpx solid #1D93FF;
					border-radius: 30rpx;
					font-size: 28rpx;
					font-family: Microsoft YaHei;
					color: #1D93FF;
					text-align: center;
					line-height: 60rpx;
				}
			}
		}
	}

	.tabLists {
		width: 100%;
		height: 218rpx;
		padding: 0 10rpx;

		.img {
			height: 100%;
		}

		.text {
			font-weight: 500;
			font-size: 45rpx;
		}
	}
	.main {
		// padding: 30rpx;
	
		.item-robot {
			// height: 190rpx;
			background-color: rgba(255, 255, 255, 0.7);
			border-radius: 20rpx;
			padding: 10rpx 30rpx;
			margin: 20rpx 0;
	
			.lt {
				width: 128rpx;
				height: 100%;
				height: 190rpx;
				margin-right: 20rpx;
	
			}
			.lt1{
				width: 128rpx;
				height: 128rpx;
			}
			.rt {
				flex: 1;
				
				& view:nth-child(1) {
					font-family: PingFang SC, PingFang SC;
					font-weight: bold;
					font-size: 32rpx;
					color: #232323;
					line-height: 38rpx;
				}
	
				& view:nth-child(2) {
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					font-size: 24rpx;
					color: #939393;
				}
				.name1{
					font-weight: 400;
					font-size: 22rpx;
					color: #939393;
				}
				.name2{
					font-weight: 400;
					font-size: 20rpx;
					color: #595959;
					margin-top: 8rpx;
				}
				.price {
					font-family: DIN, DIN;
					font-weight: bold;
					font-size: 28rpx;
					color: #FF4201;
					line-height: 56rpx;
				}
			}
		}
	}
	.shopBox {
		// background-color: #F5F9FF;
		padding: 0 30rpx;
		position: relative;
		margin-top: -20rpx;
		background: #ffffff00;
		backdrop-filter: blur(10px);
		box-shadow: 0 0 10px #ffffff00;
		border-radius: 20px 20px 0 0;
		// height: 100%;

		.shopList {
			// column-count: 2;
			// column-gap: 30rpx;
			// display: flex;
			// flex-wrap: wrap;
			// justify-content: space-between;

			.shop-item {
				display: flex;
				align-items: center;
				background: rgba(255, 255, 255, 0.7);
				height: 190rpx;
				border-radius: 20rpx 20rpx 20rpx 20rpx;
				margin-top: 15rpx;
				border: 1rpx solid rgba(255, 255, 255, 0.7);
				.image{
					width: 148rpx;
					height: 148rpx;
				}
				.stock{
					font-size: 20rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					color: #999999;
					margin-left: 20rpx;
				}
				.shop-title {
					padding: 0 20rpx;

					h3 {
						font-family: PingFang SC, PingFang SC;
						font-weight: bold;
						font-size: 28rpx;
						// color: #FFFFFF;
						line-height: 33rpx;
						text-align: left;
						font-style: normal;
						text-transform: none;
						margin-left: 10rpx;
						margin-bottom: 20rpx;
					}

					.bottom {
						display: flex;
						justify-content: space-between;
						align-items: center;

						.left {
							color: #FF4201;

							.price {
								font-family: DIN, DIN;
								font-weight: bold;
								font-size: 38rpx;
								color: #FF4201;
								line-height: 56rpx;
								text-align: left;
								font-style: normal;
								text-transform: none;

							}
						}

					}
				}



			}
		}
	}
</style>